package Inherit;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86184
 * Date: 2023-02-12
 * Time: 14:23
 */
class Animal{
    public String name;
    public int age;
    public void barks(){
        System.out.println(name+"正在摇尾巴"+" 年龄："+age);
    }
}
class Dog extends Animal{
    public void eat(){
        System.out.println(name+"正在吃饭");
    }
}
class Cat extends Animal{
    public void run(){
        System.out.println(name+"正在抓老鼠");
    }
}

public class Text1 {
    public static void main(String[] args) {
        Dog dog=new Dog();
        dog.name="旺财";
        dog.age=10;
        dog.barks();
        dog.eat();

        Cat cat=new Cat();
        cat.name="小喵";
        cat.age=5;
        cat.barks();
        cat.run();
    }
}
